package br.phb.cgame.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.View;
import br.phb.cgame.sprites.BasicSprite;

public class SpriteView extends View {
	Paint paint = new Paint();
	private BasicSprite sprite;

	public SpriteView( Context context, BasicSprite sprite ) {
		super( context );
		this.sprite = sprite;
	}

	@Override
	protected void onDraw( Canvas canvas ) {
		Rect position = new Rect( sprite.positionX, sprite.positionY, sprite.positionX + sprite.getWidth(), sprite.positionY + sprite.getHeight() );
		canvas.drawBitmap( sprite.getFrames(), sprite.getFrameRect(), position, paint );
		canvas.restore();
	}

}
